package com.easy.controller;

import com.easy.bean.Inventory;
import com.easy.service.InventoryService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("inventory")
public class InventoryController {
    @Autowired
    private InventoryService inventoryService;
    @PostMapping
    public Result add(@RequestBody Inventory inventory) {
        Object obj = inventoryService.add(inventory);
        return Result.success(obj);
    }
    @PutMapping
    public Result edit(@RequestBody Inventory inventory) {
        Object obj = inventoryService.edit(inventory);
        return Result.success(obj);
    }
    @DeleteMapping("{stock_id}")
    public Result del(@PathVariable("stock_id") int id) {
        Object obj = inventoryService.del(id);
        return Result.success(obj);
    }
    @GetMapping("{stock_id}")
    public Result one(@PathVariable("stock_id") int id) {
        Object obj = inventoryService.one(id);
        return Result.success(obj);
    }
    @GetMapping("all")
    public Result all(Inventory inventory) {
        Object obj = inventoryService.all(inventory);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, Inventory inventory) {

        inventoryService.page(page, inventory);
        return Result.success(page);
    }
}
